package com.fzq.service.impl;

import com.fzq.service.MaskingStrategy;
import org.springframework.stereotype.Component;

@Component
public class PhoneMaskingStrategy implements MaskingStrategy {

    /**
     * 手机号脱敏
     * @param value 原始字符串
     * @param pattern 脱敏模式（可选）
     * @return
     */
    @Override
    public String mask(String value, String pattern) {
        if (value == null || value.length() < 7) {
            return value;
        }
        return value.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
    }
}
